interface Car {
    String driver();
}

class Benz implements Car {
    @Override
    public String driver() {
        return "开奔驰";
    }
}

class Audi implements Car {
    @Override
    public String driver() {
        return "开奥迪";
    }
}

class Bmw implements Car {
    @Override
    public String driver() {
        return "开宝马";
    }
}

interface Driver {
    Car getCar();
}

class BenzDriver implements Driver {
    @Override
    public Car getCar() {
        return new Benz();
    }
}

class AudiDriver implements Driver {
    @Override
    public Car getCar() {
        return new Audi();
    }
}

class BmwDriver implements Driver {
    @Override
    public Car getCar() {
        return new Bmw();
    }
}

// 老板聘用多个司机来开不同车(奔驰/奥迪)
public class FactoryMethodTest {

    static public void test(Driver dri) {
        if (dri == null) {
            dri = new BmwDriver();
        }
        Car car = dri.getCar();
        System.out.printf("老板叫司机%s去见客户!\n", car.driver());
    }

    static public void main(String [] args) {
        test(new BenzDriver());
        test(new AudiDriver());
        test(new BmwDriver());
        test(null);
    }
}
